package com.bigdata

object TraitTest {
  def main(args: Array[String]): Unit = {
    // 创建对象，可以调用这个对象的父接口的属性和方法
    val worker = new Worker()
    worker.read("zhangsan")
    worker.listen("lisi")
    println(worker.listenType)
    println(worker.readType)
    // 不知道用哪个， 必须要在class中自己overwrite，否则的话直接报错
    println(worker.gender)

  }
}

trait Read {
  val readType = "Read"
  val gender = "m"

  def read(name: String) {
    println(name + " is reading")
  }
}

trait Listen {
  val listenType = "Listen"
  val gender = "w"

  def listen(name: String) {
    println(name + " is listenning")
  }
}

// extends 关键字继承 trait
class Worker() extends Read with Listen {
  override val gender = "f"
}
